#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
//int main()
//{
//	double t = 0.2648;
//	double c = 0;
//	c = 0.79618 - 0.02284 * t - 0.00679 / 2 * t * (t - 1) - 0.00316 * t * (t - 1) * (t - 2)/6;
//	printf("%lf", c);
//	return 0;
//}

int pivotIndex(int* nums, int numsSize) {
    if (numsSize == 1)
        return 0;
    int sum = 0;
    for (int i = 0; i < numsSize; i++)
    {
        sum += nums[i];
    }
    if (sum - nums[0] == 0)
    {
        return 0;
    }
    for (int i = 0; i < numsSize; i++)
    {
        if ((sum - nums[i]) % 2 != 0)
            continue;
        int sum1 = 0;
        for (int j = 0; j < i; j++)
        {
            sum1 += nums[j];
        }
        if (sum1 == (sum - nums[i]) / 2)
            return i;
    }
    if (sum - nums[numsSize - 1] == 0)
    {
        return numsSize - 1;
    }
    return -1;
}